import request from '@/utils/request'
import { praseStrEmpty } from "@/utils/ruoyi";

// 查询商品列表
export function listGoods(data) {
  return request({
    url: '/ganxin/server/getOnesList',
    method: 'get',
    params: data
  })
}

// 查询待审核商品列表
export function listGoodsAuth(data) {
  return request({
    url: '/ganxin/auth/goodsAuthList',
    method: 'get',
    params: data
  })
}

// 审核商品
export function authGoods(data) {
  return request({
    url: '/ganxin/auth/goodsAuth',
    method: 'post',
    data: data
  })
}
// 重新提交商品审核
export function reAuthGoods(data) {
  return request({
    url: '/ganxin/auth/reGoodsAuth',
    method: 'post',
    data: data
  })
}

// 查询商品详细
export function getGoods(goodsId) {
  return request({
    url: '/ganxin/server/getOneGoods/' + praseStrEmpty(goodsId),
    method: 'get'
  })
}

// 新增
export function addGoods(data) {
  return request({
    url: '/ganxin/server/saveGoods',
    method: 'post',
    data: data
  })
}

// 修改商品
export function updateGoods(data) {
  return request({
    url: '/ganxin/server/updateGoods',
    method: 'post',
    data: data
  })
}

// 删除商品
export function delGoods(goodsId) {
  return request({
    url: '/ganxin/server/deleteGoods/' + goodsId,
    method: 'get'
  })
}

// 审核状态修改
export function changeGoodsStatus(goodsId, status) {
    const data = {
      goodsId,
      status
    }
    return request({
      url: '/shop/uploadpro/changeStatus',
      method: 'put',
      data: data
    })
  }

//   商品图片上传
export function uploadImg(fileobj) {
  let param = new FormData();
  // 上传文件对象 名称file与后台控制器参数要一致
  param.append('multipartFiles',fileobj.file);
  return request({
    url: '/file/upload',
    method: 'post',
    // 定义上传头
    headers: {'Content-Type':'multipart/form-data'},
    data: param
  })
}

//添加分类
export function addClassify(data) {
  return request({
    url: '/ganxin/brand/addClassify',
    method: 'post',
    data: data
  })
}

//查询分类列表
// /ganxin/brand/getClassify?classifyName=
export function getClassify(query) {
  return request({
    url: '/ganxin/brand/getClassify',
    method: 'get',
    params: query
  })
}

//查询品牌列表
export function getBrand(data) {
  return request({
    url: '/ganxin/brand/getBrand',
    method: 'get',
    params: data
  })
}

//添加商品品牌
export function addBrand(data) {
  return request({
    url: '/ganxin/brand/addBrand',
    method: 'post',
    data: data
  })
}

//删除商品品牌
export function delBrand(brandId) {
  return request({
    url: '/ganxin/brand/delBrand/' + brandId,
    method: 'get'
  })
}


